package com.jaws.demo.feign.fallback;

import org.springframework.stereotype.Component;

import com.jaws.core.common.vo.OpResponse;
import com.jaws.demo.common.exception.ClientDemoExceptionCode;
import com.jaws.demo.feign.CloudServerFeign;
import com.jaws.demo.vo.UserVO;

/**
 * 服务降级
 * @author maojian
 * @date 2018-03-09 17:09:32
 * @since v1.0.0
 */
@Component 
public class CloudServerFeignFallback implements CloudServerFeign{

	@Override
	public OpResponse<String> getHi(String name) {
		OpResponse<String> res = OpResponse.fail(500, "local", "");
		res.setContent("local");
		return res;
	}

	@Override
	public OpResponse<UserVO> postHi(UserVO req) {
		return null;
	}

	@Override
	public OpResponse<String> getHiFallback() {
		OpResponse<String> res = OpResponse.fail(500, "local", "");
		res.setContent("this is hystrix fallback");
		return res;
	}

	@Override
	public OpResponse<String> postHiFallback() {
		throw ClientDemoExceptionCode.HYSTRIX_ERROR.exp();
	}
	
}